import request from '@/utils/request'
import { download } from '@/utils/request'
import Cookies from 'js-cookie'

// 查询会员列表
export function listUser(query) {
  return request({
    url: '/businessCore/faUser/list',
    method: 'get',
    params: query
  })
}

// 查询会员详细
export function getUser(id) {
  return request({
    url: '/businessCore/faUser/getUserInfoByUserId/' + id,
    method: 'get'
  })
}

// 新增会员
export function addUser(data) {
  const params = {createBy: Cookies.get('username')}
  return request({
    url: '/businessCore/faUser/addUser',
    method: 'post',
    data: {...data, ...params}
  })
}

// 修改会员
export function updateUser(data) {
  const params = {updateBy: Cookies.get('username')}
  return request({
    url: '/businessCore/faUser/updateFaUserInfo',
    method: 'put',
    data: {...data, ...params}
  })
}

// 删除会员
export function delUser(id) {
  return request({
    url: '/businessCore/faUser/deleteFaUserByIds/' + id,
    method: 'delete'
  })
}

// 导出会员
export function exportUser(params, fileName) {
  const url = '/businessCore/faUser/export'
  download(
    url,
    params,
    fileName + `_${new Date().getTime()}.xlsx`
  )
}